<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Http\Traits\Auth\SocialiteTrait;

class LogoutController extends Controller
{
    use SocialiteTrait;

    /**
     * 退出登录
     *
     * @return \Illuminate\Http\RedirectResponse
     */
    public function logout()
    {

        if ($this->check()) {
            // 退出登录
            $this->guard()->logout();

            // 清掉session
            session()->invalidate();
        }

        // 退出第三方登录状态
        $this->forgetSocialite();

        return $this->redirect('/');
    }

}